package com.h3c.nem.controller;

import com.h3c.nem.client.IttpClient;
import com.h3c.nem.dto.SdAllWorkerDTO;
import com.h3c.nem.dto.client.IttpClientDTO;
import com.h3c.nem.entity.SdAllWorker;
import com.h3c.nem.service.CommService;
import com.h3c.nem.service.IttpClientService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;

@CrossOrigin
@RestController
@RequestMapping("/ittp")
public class IttpController {

    @Resource
    IttpClientService ittpClientService;

    @Resource
    CommService commService;

    @Resource
    IttpClient ittpClient;

    @PostMapping("/getIttpPostDeptList")
    public HashMap<String, String> getIttpPostDeptList(@RequestBody SdAllWorkerDTO workerDTO){
        SdAllWorker sdAllWorker = commService.getAllWorkerDoFromLocalCache(workerDTO.getWorkerId());
        IttpClientDTO ittpClientDTO = new IttpClientDTO();
        ittpClientDTO.setDeptCode2(String.valueOf(sdAllWorker.getDept2id()));
        HashMap<String, String> postDeptList = ittpClientService.getPostDeptList(ittpClientDTO);
        System.out.println(postDeptList);
        return postDeptList;
    }
}
